<?php

namespace Addons\Adfloat;
use Common\Controller\Addon;

/**
 * 广告悬浮插件
 * @author 小星星
 */

    class AdfloatAddon extends Addon{

        public $info = array(
            'name'=>'Adfloat',
            'title'=>'广告悬浮',
            'description'=>'广告悬浮插件',
            'status'=>0,
            'author'=>'小星星',
            'version'=>'0.2'
        );

        public $admin_list = array(
            'model'=>'xfimage',		//要查的表
                            'fields'=>'*',			//要查的字段

        );

        public $custom_adminlist = 'adminlist.html';

        public function install(){
            $prefix = C("DB_PREFIX");
            D()->execute("DROP TABLE IF EXISTS `{$prefix}xfimage`");
            D()->execute(<<<SQL
CREATE TABLE IF NOT EXISTS `{$prefix}xfimage` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `status` int(5) NOT NULL DEFAULT '0',
  `desc`  VARCHAR (30) NOT NULL,
  `height` int(6) NOT NULL DEFAULT 50,
  `width`  int(6) NOT NULL DEFAULT 100,
  `url`varchar(30) NOT NULL,
  `img` VARCHAR (30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
SQL
            );
            return true;
        }

        public function uninstall(){
            $prefix = C("DB_PREFIX");
            D()->execute("DROP TABLE IF EXISTS `{$prefix}xfimage`");
            return true;
        }

        //实现的indexsus钩子方法
        public function float($param){
            //echo "ddd";die;
            $list = D('Addons://Adfloat/Adfloat')->linkList();
            //var_dump($list);
            //die;
            if($list['status']==0){
                return false;
            }
            $this->assign('list',$list);
            $this->display('float');
        }

    }